#!/usr/bin/env node

const chalk = require('chalk');
const inquirer = require("inquirer")

var figlet = require('figlet');
require('shelljs/global');




const textPromise = () => {

  return new Promise(function (resolve, reject) {
    figlet.text('1902A', {
      font: 'Crazy',
      horizontalLayout: 'default',
      verticalLayout: 'default',
      width: 80,
      whitespaceBreak: true
    }, function (err, data) {
      if (err) {
        console.log('Something went wrong...');
        console.dir(err);
        return;
      }

      // console.log(chalk.hex('#e56045')(`${data}`));
      resolve(data);
      
    });
  })

}



var argv = require('yargs').option('n', {
  alias: 'name',
  demand: true,
  default: '小洪',
  describe: '你的名字',
  type: 'string'
})
  .usage('Usage: hello [options]')
  .example('hello -n tom', 'say hello to Tom')
  .help('h')
  .alias('h', 'help')
  .epilog('copyright 2015')
  .command("pwa", "manifast", async function (yargs) {

    



  const text = await textPromise();
  // console.log(text);

  console.log(chalk.hex('#e56045')(`${text}`))
    console.log('\n\n');

    const {name, show_name} = await inquirer
        .prompt([
          {
            name: "name",
            type: "input",
            message: "请输入APP名称(name)?",
          },
          {
            name: "show_name",
            type: "input",
            message: "请输入短名称(short_name)?",
          },
        ]);

        console.log(name, show_name);


        let aa = await yargs;
        // console.log(aa.argv.n, 'xxx');
        echo(aa.argv.n)


        // .then((answer) => {
        //   console.log("Hello", answer.first_name, answer.last_name);
        // });

  })
  .command("e", "good evening", function (yargs) {
    console.log("Good Evening");
  })
  .argv;

  console.log(argv, 'xxx');
  // argv.then(function (res) {
  //   console.log(argv);
  // })

